//
// Created by 张朝辉 on 2023/10/8.
//

#ifndef FA_LEARNING_DPDA_H
#define FA_LEARNING_DPDA_H

#include <set>
#include <utility>
#include <map>
#include <stack>
#include <string>
#include <algorithm>
#include "tuple.h"

class DPDA {
private:
    std::set<std::string> state_set;
    std::set<char> char_set;
    std::set<char> stack_charset;
    std::map<Tuple3,std::pair<std::string,std::string>> rule_table;
    std::string start_state;
    char start_char;
    std::set<std::string> final_set;
    std::stack<char> sk;
    std::pair<std::string,char> now_state;            // 当前的自动机状态,包含当前状态和栈顶符号

    /*
     * 状态转换，转换成功返回true并修改自动机当前状态，否则返回false
     */
    auto state_transition(Tuple3 t) -> bool;
public:
    DPDA(std::set<std::string> state_set,std::set<char> char_set,std::set<char> stack_charset,
         std::map<Tuple3,std::pair<std::string,std::string>> rule_table,std::string start_state,char start_char,std::set<std::string> final_set);
    /*
     * 判断某个字符串能否被此DPDA接受
     */
    auto isAccept_str(std::string str) -> bool;

    /*
     * 打印DPDA的相关信息
     */
    auto description() -> void;
};


#endif //FA_LEARNING_DPDA_H
